using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SettingsDialog : DialogBase
{
    private AudioSource musicSource;
    [SerializeField] private Slider musicSlider;

    private void Start()
    {
        musicSource = GameObject.Find("Audio Manager").GetComponent<AudioSource>();
        // 音乐滑杆监听器
        musicSlider.onValueChanged.AddListener((value) =>
        {
            musicSource.volume = musicSlider.value;
            DataManager.Instance.MusicSettingValue = musicSlider.value; // 将当前滑杆的值存给DataManager
            
            DataManager.Instance.SaveMusicSetting();
        });
    }
    

    public override void Open()
    {
        base.Open();
        musicSlider.value = DataManager.Instance.MusicSettingValue;
    }
}
